﻿#include "mainwindow.h"

#include <QApplication>
#include <QLocale>
#include <QTranslator>

BOOL EnablePriv()//提升本程序进程为se_debug特权
{
HANDLE hToken;
if ( OpenProcessToken(GetCurrentProcess(),TOKEN_ADJUST_PRIVILEGES,&hToken) )
{
       TOKEN_PRIVILEGES tkp;

       LookupPrivilegeValue( NULL,SE_DEBUG_NAME,&tkp.Privileges[0].Luid );//修改进程权限
       tkp.PrivilegeCount=1;
       tkp.Privileges[0].Attributes=SE_PRIVILEGE_ENABLED;
       AdjustTokenPrivileges( hToken,FALSE,&tkp,sizeof tkp,NULL,NULL );//通知系统修改进程权限

       return( (GetLastError()==ERROR_SUCCESS) );
}
       return TRUE;
}

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QTranslator translator;
    const QStringList uiLanguages = QLocale::system().uiLanguages();
    for (const QString &locale : uiLanguages) {
        const QString baseName = "neicunsaomian_" + QLocale(locale).name();
        if (translator.load(":/i18n/" + baseName)) {
            a.installTranslator(&translator);
            break;
        }
    }
    EnablePriv();
    MainWindow w;
    w.show();
    return a.exec();
}
